package com.heima.article.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleMapper;
import com.heima.article.mapper.ApAuthorMapper;
import com.heima.article.service.ApArticleService;
import com.heima.article.service.ApAuthorServise;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @创建人: stone
 * @描述:
 */
@Service
@Transactional
@Slf4j
public class ApAuthorServiseImpl extends ServiceImpl<ApAuthorMapper, ApAuthor> implements ApAuthorServise {
    /**
     * 创建文章账户
     *
     * @param apAuthor
     * @return
     */
    @Override
    public ResponseResult register(ApAuthor apAuthor) {

        if (apAuthor.getId() == null) {
            save(apAuthor);
        } else {
            updateById(apAuthor);
        }
        return ResponseResult.okResult(apAuthor.getId());
    }
}
